import time
from umodbus.serial import Serial as ModbusRTUMaster


host = ModbusRTUMaster(
    pins = (17, 16),  # (TX, RX)
    baudrate = 9600,
    uart_id = 2,
)


def read_hold():
    regs = host.read_holding_registers(
        slave_addr = 1,
        starting_addr = 0,
        register_qty = 1,
        signed=True
    )
    print(regs)


while (True):
    time.sleep(1)
    
    try:
        read_hold()
    except OSError as e:
        print(e)
